package com.wcl.demo.db;

import com.wcl.demo.model.entity.AroundInfor;
import com.wcl.demo.model.entity.AroundInforDao;

import java.util.List;

/**
 * Created by dllo on 15/11/30.
 */
public class AroundHelper {
    private DaoSingleton instance = DaoSingleton.getInstance();
    private AroundInforDao aroundInforDao;

    public AroundHelper() {
        aroundInforDao = instance.getAroundInforDao();
    }
    public void saveAroundInfor(List<AroundInfor> aroundInfors){
        aroundInforDao.insertInTx(aroundInfors);
    }
    /***
     * 删除
     */
    public void deleteAll() {
        aroundInforDao.deleteAll();
    }

    /***
     * 查询
     */
    public List<AroundInfor> queryAll() {
        return aroundInforDao.loadAll();
    }

    /**
     * 倒叙输出
     * @return
     */
    public List<AroundInfor> queryAllOrder(){
       return aroundInforDao.queryBuilder().orderDesc(AroundInforDao.Properties.Around_id_message).list();

    }
    /**
     * 按自增长id查询
     */
    public List<AroundInfor> queryById(long id){
        List<AroundInfor> list=aroundInforDao.queryBuilder().where(AroundInforDao.Properties.Around_id_message.eq(id)).list();
        return list;
    }
}
